import 'package:flutter/material.dart';

class CardBindPage extends StatefulWidget {
  @override
  _CardBindPageState createState() => _CardBindPageState();
}

class _CardBindPageState extends State<CardBindPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: new AppBar(
        centerTitle: true,
        backgroundColor: Colors.white,
        iconTheme: IconThemeData(
        color: Colors.black
    ),
    title: new Text(
    '银行卡绑定',
    style: new TextStyle(color: Colors.black),
    ),
    ),
    body: new SingleChildScrollView(
      child: new Container(
        child: Column(
          children: <Widget>[
            new Offstage(
              offstage:  false,
              child:  new Container(
                child:  new Row(
                  children: <Widget>[
                    Expanded(
                      child: new Text('绑定的银行卡仅用于定期理财产品到期后的利息（法币形式）结算，原则上只能绑定一张银行卡。在您所购买的产品到期后利息结算完毕后可以解绑。',
                        style: new TextStyle(color: Color(0xffffa169),fontSize: 14.0),
                      ),
                      flex: 1,
                    ),
                    new GestureDetector(
                      onTap: (){},
                      child:Image.asset('images/icon_error.png',width: 20.0,height: 20.0,)
                      ,)

                  ],
                ),
                color: Color(0xFFFCF8FF) ,
                padding: EdgeInsets.fromLTRB(15.0, 0.0, 15.0, 0.0),
                height: 80.0,
              ),
            ),
            new Container(
              height: 51.0,
              padding: EdgeInsets.fromLTRB(15.0, 0.0, 15.0, 0.0),

              color: Color(0xFFF6F5F5),
              child:new Row(
                children: <Widget>[
                  Expanded(child:
                  new Text('填写银行卡信息',style: new TextStyle(
//                        fontWeight: FontWeight.bold,
                      fontSize: 15.0,
                      fontWeight: FontWeight.bold,
                      color: Color(0xFF333333))
                  ),
                    flex: 1,),
                  new Text('')
                ],
              ),
            ),
            commentTitle(context,1,1,'银行         ','请选择银行'),
            commentTitle(context,2,2,'开户行      ','请输入开户行名称'),
            commentTitle(context,3,2,'银行卡号   ','请输入准确的银行卡卡号'),
            commentTitle(context,4,2,'持卡人姓名','请输入您的真实姓名'),
            commentTitle(context,5,2,'手机号       ','银行留存银行手机号'),

            new Container(
              height: 40.0,
              width: 400.0,
              margin: EdgeInsets.all(15.0),
              child:  RaisedButton(onPressed: (){
                showAlertDialog(context);
              },
                color: Color(0xFFB969FF),
                child: Text('下一步' ,style: TextStyle(
                    fontSize: 16.0,
                    fontWeight: FontWeight.bold
                ),),
                textColor: Colors.white,


              ),
            )

          ],

        ),
      ),
    )

    );

  }
  Widget commentTitle(BuildContext context,int type,int state,String title,String hint){
    return new GestureDetector(

        child: Container(
          height: 51.0,
          padding: EdgeInsets.fromLTRB(15.0, 0.0, 15.0, 0.0),
          margin: EdgeInsets.fromLTRB(0.0, 1.0, 0.0, 0.0),
          color: Colors.white,
          child:Row(
            children: <Widget>[
              new Text(title),
              Expanded(
                child: TextField(
                  textAlign: TextAlign.end,
                keyboardType: TextInputType.text,
                style: TextStyle(
                  color: Color(0xFF666666),
                  fontSize: 13.0
                ),
                decoration: InputDecoration(
                  contentPadding: EdgeInsets.all(10.0),
                  hintText: hint,
                  labelText: hint,

                  hintStyle: TextStyle(
                    color: Color(0xFF999999),
                    fontSize: 14.0
                  ),
                  disabledBorder: InputBorder.none,
                  enabledBorder: InputBorder.none,
                  focusedBorder: InputBorder.none
                ),
                onChanged: _textFieldChanged,
                 textInputAction: TextInputAction.next,
                maxLines: 1,
              ),flex: 1,),



            ],
          ),
        ),
        onTap: () {
          switch (type) {
            case 0:
              print("num 12");
              break;
            case 1:
              print("num 15");
              break;
            case 2:
              break;
            case 3:
              break;
            case 4:

              break;
          }
        }
    );
  }
  void _textFieldChanged(String str){
    print(str);
  }


  void showAlertDialog(BuildContext context) {
    showDialog(
        context: context,
        builder: (_) => new AlertDialog(
            title: new Text("标题"),
            content: new Text("身份证绑定成功"),
            actions:<Widget>[

              new FlatButton(child:new Text("OK"), onPressed: (){
                Navigator.of(context).pop();

              },)
            ]

        ));
  }


}
